package com.qwt.part_time_api.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.qwt.part_time_api.pojo.News;
import com.qwt.part_time_api.service.NewsService;
import com.qwt.part_time_api.vo.Result;
import com.qwt.part_time_api.vo.params.PageParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 君子慎独
 * @create 2021/12/24 0024 19:44
 */
@RestController
@RequestMapping("/news")
@Api(tags = {"新闻资讯"})
public class NewsController {

    @Autowired
    private NewsService newsService;

    /**
     * 通过 0-1 来查询新闻资讯或平台公告
     *
     * @param params 0或1
     * @return 新闻资讯或平台公告
     */
    @PostMapping("/newsList")
    @ApiOperation(value = "新闻资讯或平台公告", notes = "通过 0-1 来查询新闻资讯或平台公告")
    @ApiOperationSupport(author = "Tzeao",
            includeParameters = {"params.page",
                    "params.pageSize",
                    "params.newsType"})
    @ApiResponses(@ApiResponse(code = 200, message = "成功", response = News.class))
    public Result newsList(@RequestBody PageParams params) {
        return newsService.findNewsByType(params);
    }
}
